package com.somlsis.fragment

import com.base.BaseFragment
import com.somlsis.activity.BasicInfoActivity
import com.somlsis.databinding.FragmentBodyInfoBinding
import com.widget.WheelView


class BodyInfoFragment(private val listener: BasicInfoActivity.OnBasicInfoNextClickListener) :
    BaseFragment<FragmentBodyInfoBinding>() {

    override fun getViewBinding(): FragmentBodyInfoBinding {
        return FragmentBodyInfoBinding.inflate(layoutInflater)
    }

    override fun createView() {
        binding.next.setOnClickListener {

            listener.onBodyInfoNextClick(
                binding.userWeight.text.toString(),
                binding.userHeight.text.toString()
            )
        }
        createWheelView()
    }

    override fun refreshUI() {
    }

    private fun createWheelView() {
        binding.weightWheel.setOnWheelItemSelectedListener(object :
            WheelView.OnWheelItemSelectedListener {
            override fun onWheelItemChanged(wheelView: WheelView?, position: Int) {
                binding.userWeight.text = position.toString()
            }

            override fun onWheelItemSelected(wheelView: WheelView?, position: Int) {

            }

        })
        binding.heightWheel.setOnWheelItemSelectedListener(object :
            WheelView.OnWheelItemSelectedListener {
            override fun onWheelItemChanged(wheelView: WheelView?, position: Int) {
                binding.userHeight.text = position.toString()
            }

            override fun onWheelItemSelected(wheelView: WheelView?, position: Int) {

            }

        })
    }

}